<template>
	<view class="content">
		<view class="search">
			<input v-model="searchs" type="text" value="" placeholder="请输入要搜索的商品" />
		</view>
		
		<view class="zuix" >
		<view class="imag" v-for="(item,index) in searh" :key='index'>
				<image :src="item.goods_image" mode="widthFix"></image>
				<text class="x">{{item.title}}</text>
				<view class="f">{{item.title_f}}</view>
				<view class="" style="display: flex;">
					<text class="price">￥{{item.price}}</text>
					<text class="price_q">￥{{item.oldprice}}</text>
				</view>
				<view class="lms">
					<text>销量{{item.xl}}笔</text>
					<image src="../../../static/images/s21.png" mode="widthFix" @tap='sear(item.id)'></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//搜索
				searchs:'',
				bs:1,
				courrt:1,
				searh:[],
			}
		},
		methods: {
			sear(id){
				uni.navigateTo({
					url:'../../details/details?id='+id
				})
			}
		},
		onReachBottom(){
			if(!this.searchs){
				this.$sToast('请输入要搜索的商品')
			}else{
				this.$ajax(
				this.apiList.search,
				{ 
					key:this.searchs,
					page:++this.courrt
				},
				'POST',
				).then(res=>{
				this.searh = this.searh.concat(res.data)
				if(!res.data.length){
						this.$sToast('无更多数据')
				}
				})
			}
		
		},
		watch:{
			searchs(newVaue,oldVaue){
				this.$ajax(
				this.apiList.search,
				{ 
					key:newVaue,
					page:this.courrt
				},
				'POST',
				).then(res=>{
				this.searh = res.data
				})
			},
		
		}
	}
</script>

<style lang="scss" scoped>
.content{
	width: 100%;
	height: 100vh;
	background-color: #eee;
	// box-sizing: border-box;
	 .search{
		 width: 100%;
		 // box-sizing: border-box;
		 text-align: center;
		 // height: 88upx;
		 padding: 20upx 0;
		 position: fixed;
		 left: 0;
		 top:0rpx;
		 z-index: 99;
		 background-color: #eee;
		 height: 60rpx;
		 background: #fff;
		 input {
			 position: fixed;
			 left: 4%;
			 z-index: 999;
			 display: inline-block;
			 width:690upx;
			 height:48rpx;
			 background:#f5f5f5 !important;
			 opacity:1;
			 border-radius:40px;
		 }
	}
	 .zuix {
		margin-top: 90upx;
		display: flex;
		justify-content: space-between;
		padding: 0upx 30upx 30upx 30upx;
		box-sizing: border-box;
		background-color: #eee;
		flex-wrap: wrap;
		.imag {
			width: 335rpx;
			background-color: #fff;
			margin-bottom: 30rpx;
			image {
				width: 100%;
			}
			.x {
				display: block;
				width: 100%;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 700;
				margin: 10upx;
			}
			.f{
				width: 70%;
				font-size: 28upx;
				overflow: hidden;
				color: #C0C0C0;
				flex-wrap: nowrap;
				margin-left: 23rpx;
				white-space:nowrap;
				text-overflow: ellipsis;
			}
	
			.price {
				display: block;
				width: 100%;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: rgba(226, 104, 27, 1);
				margin: 10upx;
			}
	
			.price_q {
				display: block;
				width: 100%;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 400;
				text-decoration: line-through;
				color: rgba(112, 112, 112, 1);
				margin: 10upx;
			}
	
			.lms {
				display: flex;
				justify-content: space-between;
				width: 100%;
	
				text {
					font-size: 18upx;
					font-family: PingFang SC;
					font-weight: 400;
					margin-bottom: 10upx;
					margin-left: 10upx;
				}
	
				image {
					width: 32upx;
					margin-right: 10upx;
				}
			}
		}
	}
	 .bac {
		background: url(../../../static/images/s35.png) no-repeat center ;
		background-size: 50% ;
		background-position: 50% 20%;
		}
	}
</style>
